using System;
using System.Data;
using System.Data.Common;
using System.Configuration;
using System.Data.SqlClient;

using SIS.ENT;


namespace SIS.DAL
{
    /// <summary>
    /// The EnquiryTableDB class is responsible for interacting with the database to retrieve and store information
    /// about EnquiryTable objects.
    /// </summary>
    public class EnquiryTableDB
    {
        #region "Public Methods"

        /// <summary>
        /// Gets an instance of EnquiryTable from the underlying datasource.
        /// </summary>
        /// <param name="enquiryKey">The unique EnquiryKey of the EnquiryTable in the database.</param>
        /// <returns>An EnquiryTable when the EnquiryKey was found in the database, or null otherwise.</returns>
        public static EnquiryTable GetItem(int enquiryKey)
        {
            EnquiryTable myEnquiryTable = null;
            using (SqlConnection myConnection = new SqlConnection(ConfigurationManager.ConnectionStrings["sis.dbconn"].ConnectionString))
            {
                using (SqlCommand myCommand = new SqlCommand("sprocEnquiryTableSelectSingleItem", myConnection))
                {
                    myCommand.CommandType = CommandType.StoredProcedure;
                    myCommand.Parameters.AddWithValue("@enquiryKey", enquiryKey);

                    myConnection.Open();
                    using (SqlDataReader myReader = myCommand.ExecuteReader())
                    {
                        if (myReader.Read())
                        {
                            myEnquiryTable = FillDataRecord(myReader);
                        }
                        myReader.Close();
                    }
                    myConnection.Close();
                }
                return myEnquiryTable;
            }
        }

        /// <summary>
        /// Returns a list with EnquiryTable objects.
        /// </summary>
        /// <returns>A generics List with the EnquiryTable objects.</returns>
        public static EnquiryTableList GetList()
        {
            EnquiryTableList tempList = new EnquiryTableList();
            using (SqlConnection myConnection = new SqlConnection(ConfigurationManager.ConnectionStrings["sis.dbconn"].ConnectionString))
            {
                using (SqlCommand myCommand = new SqlCommand("sprocEnquiryTableSelectList", myConnection))
                {
                    myCommand.CommandType = CommandType.StoredProcedure;

                    myConnection.Open();
                    using (SqlDataReader myReader = myCommand.ExecuteReader())
                    {
                        if (myReader.HasRows)
                        {
                            while (myReader.Read())
                            {
                                tempList.Add(FillDataRecord(myReader));
                            }
                        }
                        myReader.Close();
                    }
                }
            }
            return tempList;
        }

        /// <summary>
        /// Returns a list with EnquiryTable objects.
        /// </summary>
        /// <returns>A generics List with the EnquiryTable objects.</returns>
        public static EnquiryTableList GetListByLocationKey(int LocationKey)
        {
            EnquiryTableList tempList = new EnquiryTableList();
            using (SqlConnection myConnection = new SqlConnection(ConfigurationManager.ConnectionStrings["sis.dbconn"].ConnectionString))
            {
                using (SqlCommand myCommand = new SqlCommand("sprocEnquiryTableSelectListByLocationKey", myConnection))
                {
                    myCommand.CommandType = CommandType.StoredProcedure;
                    myCommand.Parameters.AddWithValue("@locationKey", LocationKey);
                    myConnection.Open();
                    using (SqlDataReader myReader = myCommand.ExecuteReader())
                    {
                        if (myReader.HasRows)
                        {
                            while (myReader.Read())
                            {
                                tempList.Add(FillDataRecord(myReader));
                            }
                        }
                        myReader.Close();
                    }
                }
                return tempList;
            }
        }

        /// <summary>
        /// Returns a list with EnquiryTable objects.
        /// </summary>
        /// <returns>A generics List with the EnquiryTable objects.</returns>
        public static EnquiryTableList GetListBySchoolKey(int SchoolKey)
        {
            EnquiryTableList tempList = new EnquiryTableList();
            using (SqlConnection myConnection = new SqlConnection(ConfigurationManager.ConnectionStrings["sis.dbconn"].ConnectionString))
            {
                using (SqlCommand myCommand = new SqlCommand("sprocEnquiryTableSelectListBySchoolKey", myConnection))
                {
                    myCommand.CommandType = CommandType.StoredProcedure;
                    myCommand.Parameters.AddWithValue("@schoolKey", SchoolKey);
                    myConnection.Open();
                    using (SqlDataReader myReader = myCommand.ExecuteReader())
                    {
                        if (myReader.HasRows)
                        {
                            while (myReader.Read())
                            {
                                tempList.Add(FillDataRecord(myReader));
                            }
                        }
                        myReader.Close();
                    }
                }
                return tempList;
            }
        }

        /// <summary>
        /// Saves a EnquiryTable in the database.
        /// </summary>
        /// <param name="myEnquiryTable">The EnquiryTable instance to save.</param>
        /// <returns>The new EnquiryKey if the EnquiryTable is new in the database or the existing EnquiryKey when an item was updated.</returns>
        public static int Save(EnquiryTable myEnquiryTable)
        {
            int result = 0;
            using (SqlConnection myConnection = new SqlConnection(ConfigurationManager.ConnectionStrings["sis.dbconn"].ConnectionString))
            {
                using (SqlCommand myCommand = new SqlCommand("sprocEnquiryTableInsertUpdateSingleItem", myConnection))
                {
                    myCommand.CommandType = CommandType.StoredProcedure;

                    if (myEnquiryTable.EnquiryKey == -1)
                    {
                        myCommand.Parameters.AddWithValue("@enquiryKey", DBNull.Value);
                    }
                    else
                    {
                        myCommand.Parameters.AddWithValue("@enquiryKey", myEnquiryTable.EnquiryKey);
                    }
                    if (myEnquiryTable.LocationKey == null)
                    {
                        myCommand.Parameters.AddWithValue("@locationKey", DBNull.Value);
                    }
                    else
                    {
                        myCommand.Parameters.AddWithValue("@locationKey", myEnquiryTable.LocationKey);
                    }
                    if (myEnquiryTable.SchoolKey == null)
                    {
                        myCommand.Parameters.AddWithValue("@schoolKey", DBNull.Value);
                    }
                    else
                    {
                        myCommand.Parameters.AddWithValue("@schoolKey", myEnquiryTable.SchoolKey);
                    }
                    if (string.IsNullOrEmpty(myEnquiryTable.FirstName))
                    {
                        myCommand.Parameters.AddWithValue("@firstName", DBNull.Value);
                    }
                    else
                    {
                        myCommand.Parameters.AddWithValue("@firstName", myEnquiryTable.FirstName);
                    }
                    if (string.IsNullOrEmpty(myEnquiryTable.LastName))
                    {
                        myCommand.Parameters.AddWithValue("@lastName", DBNull.Value);
                    }
                    else
                    {
                        myCommand.Parameters.AddWithValue("@lastName", myEnquiryTable.LastName);
                    }
                    if (string.IsNullOrEmpty(myEnquiryTable.OtherName))
                    {
                        myCommand.Parameters.AddWithValue("@otherName", DBNull.Value);
                    }
                    else
                    {
                        myCommand.Parameters.AddWithValue("@otherName", myEnquiryTable.OtherName);
                    }
                    if (string.IsNullOrEmpty(myEnquiryTable.Gender))
                    {
                        myCommand.Parameters.AddWithValue("@gender", DBNull.Value);
                    }
                    else
                    {
                        myCommand.Parameters.AddWithValue("@gender", myEnquiryTable.Gender);
                    }
                    if (myEnquiryTable.EnquiryType == null)
                    {
                        myCommand.Parameters.AddWithValue("@enquiryType", DBNull.Value);
                    }
                    else
                    {
                        myCommand.Parameters.AddWithValue("@enquiryType", myEnquiryTable.EnquiryType);
                    }
                    if (myEnquiryTable.EnquiryReasonType == null)
                    {
                        myCommand.Parameters.AddWithValue("@enquiryReasonType", DBNull.Value);
                    }
                    else
                    {
                        myCommand.Parameters.AddWithValue("@enquiryReasonType", myEnquiryTable.EnquiryReasonType);
                    }
                    if (string.IsNullOrEmpty(myEnquiryTable.ContactPhoneNumber))
                    {
                        myCommand.Parameters.AddWithValue("@contactPhoneNumber", DBNull.Value);
                    }
                    else
                    {
                        myCommand.Parameters.AddWithValue("@contactPhoneNumber", myEnquiryTable.ContactPhoneNumber);
                    }
                    if (string.IsNullOrEmpty(myEnquiryTable.ContactAddress))
                    {
                        myCommand.Parameters.AddWithValue("@contactAddress", DBNull.Value);
                    }
                    else
                    {
                        myCommand.Parameters.AddWithValue("@contactAddress", myEnquiryTable.ContactAddress);
                    }
                    if (string.IsNullOrEmpty(myEnquiryTable.ContactEmail))
                    {
                        myCommand.Parameters.AddWithValue("@contactEmail", DBNull.Value);
                    }
                    else
                    {
                        myCommand.Parameters.AddWithValue("@contactEmail", myEnquiryTable.ContactEmail);
                    }
                    if (myEnquiryTable.PreferContactTypeCode == null)
                    {
                        myCommand.Parameters.AddWithValue("@preferContactTypeCode", DBNull.Value);
                    }
                    else
                    {
                        myCommand.Parameters.AddWithValue("@preferContactTypeCode", myEnquiryTable.PreferContactTypeCode);
                    }
                    if (myEnquiryTable.RelationshipTypeCode == null)
                    {
                        myCommand.Parameters.AddWithValue("@relationshipTypeCode", DBNull.Value);
                    }
                    else
                    {
                        myCommand.Parameters.AddWithValue("@relationshipTypeCode", myEnquiryTable.RelationshipTypeCode);
                    }
                    if (string.IsNullOrEmpty(myEnquiryTable.Message))
                    {
                        myCommand.Parameters.AddWithValue("@message", DBNull.Value);
                    }
                    else
                    {
                        myCommand.Parameters.AddWithValue("@message", myEnquiryTable.Message);
                    }
                    if (string.IsNullOrEmpty(myEnquiryTable.Remark))
                    {
                        myCommand.Parameters.AddWithValue("@remark", DBNull.Value);
                    }
                    else
                    {
                        myCommand.Parameters.AddWithValue("@remark", myEnquiryTable.Remark);
                    }
                    if (string.IsNullOrEmpty(myEnquiryTable.OtherInfo))
                    {
                        myCommand.Parameters.AddWithValue("@otherInfo", DBNull.Value);
                    }
                    else
                    {
                        myCommand.Parameters.AddWithValue("@otherInfo", myEnquiryTable.OtherInfo);
                    }

                    myCommand.Parameters.AddWithValue("@status", myEnquiryTable.Status);

                    //if (myEnquiryTable.Status == null)
                    //{
                    //    myCommand.Parameters.AddWithValue("@status", DBNull.Value);
                    //}
                    //else
                    //{
                    //    myCommand.Parameters.AddWithValue("@status", myEnquiryTable.Status);
                    //}
                    
                    //if (myEnquiryTable.CreatedDateTime == null)
                    //{
                    //    myCommand.Parameters.AddWithValue("@createdDateTime", DBNull.Value);
                    //}
                    //else
                    //{
                    //    myCommand.Parameters.AddWithValue("@createdDateTime", myEnquiryTable.CreatedDateTime);
                    //}
                    //if (myEnquiryTable.ModifiedDateTime == null)
                    //{
                    //    myCommand.Parameters.AddWithValue("@modifiedDateTime", DBNull.Value);
                    //}
                    //else
                    //{
                    //    myCommand.Parameters.AddWithValue("@modifiedDateTime", myEnquiryTable.ModifiedDateTime);
                    //}
                    //if (string.IsNullOrEmpty(myEnquiryTable.Info1))
                    //{
                    //    myCommand.Parameters.AddWithValue("@info1", DBNull.Value);
                    //}
                    //else
                    //{
                    //    myCommand.Parameters.AddWithValue("@info1", myEnquiryTable.Info1);
                    //}
                    //if (string.IsNullOrEmpty(myEnquiryTable.Info2))
                    //{
                    //    myCommand.Parameters.AddWithValue("@info2", DBNull.Value);
                    //}
                    //else
                    //{
                    //    myCommand.Parameters.AddWithValue("@info2", myEnquiryTable.Info2);
                    //}
                    //if (string.IsNullOrEmpty(myEnquiryTable.Info3))
                    //{
                    //    myCommand.Parameters.AddWithValue("@info3", DBNull.Value);
                    //}
                    //else
                    //{
                    //    myCommand.Parameters.AddWithValue("@info3", myEnquiryTable.Info3);
                    //}
                    //if (string.IsNullOrEmpty(myEnquiryTable.Info4))
                    //{
                    //    myCommand.Parameters.AddWithValue("@info4", DBNull.Value);
                    //}
                    //else
                    //{
                    //    myCommand.Parameters.AddWithValue("@info4", myEnquiryTable.Info4);
                    //}
                    //if (string.IsNullOrEmpty(myEnquiryTable.Info5))
                    //{
                    //    myCommand.Parameters.AddWithValue("@info5", DBNull.Value);
                    //}
                    //else
                    //{
                    //    myCommand.Parameters.AddWithValue("@info5", myEnquiryTable.Info5);
                    //}
                    //if (string.IsNullOrEmpty(myEnquiryTable.Info6))
                    //{
                    //    myCommand.Parameters.AddWithValue("@info6", DBNull.Value);
                    //}
                    //else
                    //{
                    //    myCommand.Parameters.AddWithValue("@info6", myEnquiryTable.Info6);
                    //}
                    //if (string.IsNullOrEmpty(myEnquiryTable.Info7))
                    //{
                    //    myCommand.Parameters.AddWithValue("@info7", DBNull.Value);
                    //}
                    //else
                    //{
                    //    myCommand.Parameters.AddWithValue("@info7", myEnquiryTable.Info7);
                    //}
                    //if (string.IsNullOrEmpty(myEnquiryTable.Info8))
                    //{
                    //    myCommand.Parameters.AddWithValue("@info8", DBNull.Value);
                    //}
                    //else
                    //{
                    //    myCommand.Parameters.AddWithValue("@info8", myEnquiryTable.Info8);
                    //}
                    //if (string.IsNullOrEmpty(myEnquiryTable.Info9))
                    //{
                    //    myCommand.Parameters.AddWithValue("@info9", DBNull.Value);
                    //}
                    //else
                    //{
                    //    myCommand.Parameters.AddWithValue("@info9", myEnquiryTable.Info9);
                    //}
                    //if (string.IsNullOrEmpty(myEnquiryTable.Info10))
                    //{
                    //    myCommand.Parameters.AddWithValue("@info10", DBNull.Value);
                    //}
                    //else
                    //{
                    //    myCommand.Parameters.AddWithValue("@info10", myEnquiryTable.Info10);
                    //}
                    //if (myEnquiryTable.DInfo1 == null)
                    //{
                    //    myCommand.Parameters.AddWithValue("@dInfo1", DBNull.Value);
                    //}
                    //else
                    //{
                    //    myCommand.Parameters.AddWithValue("@dInfo1", myEnquiryTable.DInfo1);
                    //}
                    //if (myEnquiryTable.DInfo2 == null)
                    //{
                    //    myCommand.Parameters.AddWithValue("@dInfo2", DBNull.Value);
                    //}
                    //else
                    //{
                    //    myCommand.Parameters.AddWithValue("@dInfo2", myEnquiryTable.DInfo2);
                    //}
                    //if (myEnquiryTable.DInfo3 == DateTime.MinValue)
                    //{
                    //    myCommand.Parameters.AddWithValue("@dInfo3", DBNull.Value);
                    //}
                    //else
                    //{
                    //    myCommand.Parameters.AddWithValue("@dInfo3", myEnquiryTable.DInfo3);
                    //}
                    //if (myEnquiryTable.DInfo4 == DateTime.MinValue)
                    //{
                    //    myCommand.Parameters.AddWithValue("@dInfo4", DBNull.Value);
                    //}
                    //else
                    //{
                    //    myCommand.Parameters.AddWithValue("@dInfo4", myEnquiryTable.DInfo4);
                    //}
                    //if (myEnquiryTable.NInfo1 == null)
                    //{
                    //    myCommand.Parameters.AddWithValue("@nInfo1", DBNull.Value);
                    //}
                    //else
                    //{
                    //    myCommand.Parameters.AddWithValue("@nInfo1", myEnquiryTable.NInfo1);
                    //}
                    //if (myEnquiryTable.NInfo2 == null)
                    //{
                    //    myCommand.Parameters.AddWithValue("@nInfo2", DBNull.Value);
                    //}
                    //else
                    //{
                    //    myCommand.Parameters.AddWithValue("@nInfo2", myEnquiryTable.NInfo2);
                    //}
                    //if (myEnquiryTable.NInfo3 == null)
                    //{
                    //    myCommand.Parameters.AddWithValue("@nInfo3", DBNull.Value);
                    //}
                    //else
                    //{
                    //    myCommand.Parameters.AddWithValue("@nInfo3", myEnquiryTable.NInfo3);
                    //}
                    //if (myEnquiryTable.Ninfo4 == null)
                    //{
                    //    myCommand.Parameters.AddWithValue("@ninfo4", DBNull.Value);
                    //}
                    //else
                    //{
                    //    myCommand.Parameters.AddWithValue("@ninfo4", myEnquiryTable.Ninfo4);
                    //}
                    //if (myEnquiryTable.NInfo5 == null)
                    //{
                    //    myCommand.Parameters.AddWithValue("@nInfo5", DBNull.Value);
                    //}
                    //else
                    //{
                    //    myCommand.Parameters.AddWithValue("@nInfo5", myEnquiryTable.NInfo5);
                    //}
                    //if (myEnquiryTable.NInfo6 == null)
                    //{
                    //    myCommand.Parameters.AddWithValue("@nInfo6", DBNull.Value);
                    //}
                    //else
                    //{
                    //    myCommand.Parameters.AddWithValue("@nInfo6", myEnquiryTable.NInfo6);
                    //}
                    //if (myEnquiryTable.NInfo7 == null)
                    //{
                    //    myCommand.Parameters.AddWithValue("@nInfo7", DBNull.Value);
                    //}
                    //else
                    //{
                    //    myCommand.Parameters.AddWithValue("@nInfo7", myEnquiryTable.NInfo7);
                    //}
                    //if (myEnquiryTable.NInfo8 == null)
                    //{
                    //    myCommand.Parameters.AddWithValue("@nInfo8", DBNull.Value);
                    //}
                    //else
                    //{
                    //    myCommand.Parameters.AddWithValue("@nInfo8", myEnquiryTable.NInfo8);
                    //}

                    DbParameter returnValue;
                    returnValue = myCommand.CreateParameter();
                    returnValue.Direction = ParameterDirection.ReturnValue;
                    myCommand.Parameters.Add(returnValue);

                    myConnection.Open();
                    myCommand.ExecuteNonQuery();
                    result = Convert.ToInt32(returnValue.Value);
                    myConnection.Close();
                }
            }
            return result;
        }

        /// <summary>
        /// Deletes a EnquiryTable from the database.
        /// </summary>
        /// <param name="enquiryKey">The EnquiryKey of the EnquiryTable to delete.</param>
        /// <returns>Returns true when the object was deleted successfully, or false otherwise.</returns>
        public static bool Delete(int enquiryKey)
        {
            int result = 0;
            using (SqlConnection myConnection = new SqlConnection(ConfigurationManager.ConnectionStrings["sis.dbconn"].ConnectionString))
            {
                using (SqlCommand myCommand = new SqlCommand("sprocEnquiryTableDeleteSingleItem", myConnection))
                {
                    myCommand.CommandType = CommandType.StoredProcedure;

                    myCommand.Parameters.AddWithValue("@enquiryKey", enquiryKey);
                    myConnection.Open();
                    result = myCommand.ExecuteNonQuery();
                    myConnection.Close();
                }
            }
            return result > 0;
        }

        #endregion

        /// <summary>
        /// Initializes a new instance of the EnquiryTable class and fills it with the data fom the IDataRecord.
        /// </summary>
        private static EnquiryTable FillDataRecord(IDataRecord myDataRecord)
        {
            EnquiryTable myEnquiryTable = new EnquiryTable();
            if (!myDataRecord.IsDBNull(myDataRecord.GetOrdinal("EnquiryKey")))
            {
                myEnquiryTable.EnquiryKey = myDataRecord.GetInt32(myDataRecord.GetOrdinal("EnquiryKey"));
            }
            if (!myDataRecord.IsDBNull(myDataRecord.GetOrdinal("LocationKey")))
            {
                myEnquiryTable.LocationKey = myDataRecord.GetInt32(myDataRecord.GetOrdinal("LocationKey"));
            }
            if (!myDataRecord.IsDBNull(myDataRecord.GetOrdinal("SchoolKey")))
            {
                myEnquiryTable.SchoolKey = myDataRecord.GetInt32(myDataRecord.GetOrdinal("SchoolKey"));
            }
            if (!myDataRecord.IsDBNull(myDataRecord.GetOrdinal("FirstName")))
            {
                myEnquiryTable.FirstName = myDataRecord.GetString(myDataRecord.GetOrdinal("FirstName"));
            }
            if (!myDataRecord.IsDBNull(myDataRecord.GetOrdinal("LastName")))
            {
                myEnquiryTable.LastName = myDataRecord.GetString(myDataRecord.GetOrdinal("LastName"));
            }
            if (!myDataRecord.IsDBNull(myDataRecord.GetOrdinal("OtherName")))
            {
                myEnquiryTable.OtherName = myDataRecord.GetString(myDataRecord.GetOrdinal("OtherName"));
            }
            if (!myDataRecord.IsDBNull(myDataRecord.GetOrdinal("Gender")))
            {
                myEnquiryTable.Gender = myDataRecord.GetString(myDataRecord.GetOrdinal("Gender"));
            }
            if (!myDataRecord.IsDBNull(myDataRecord.GetOrdinal("EnquiryType")))
            {
                myEnquiryTable.EnquiryType = myDataRecord.GetInt16(myDataRecord.GetOrdinal("EnquiryType"));
            }
            if (!myDataRecord.IsDBNull(myDataRecord.GetOrdinal("EnquiryReasonType")))
            {
                myEnquiryTable.EnquiryReasonType = myDataRecord.GetInt16(myDataRecord.GetOrdinal("EnquiryReasonType"));
            }
            if (!myDataRecord.IsDBNull(myDataRecord.GetOrdinal("ContactPhoneNumber")))
            {
                myEnquiryTable.ContactPhoneNumber = myDataRecord.GetString(myDataRecord.GetOrdinal("ContactPhoneNumber"));
            }
            if (!myDataRecord.IsDBNull(myDataRecord.GetOrdinal("ContactAddress")))
            {
                myEnquiryTable.ContactAddress = myDataRecord.GetString(myDataRecord.GetOrdinal("ContactAddress"));
            }
            if (!myDataRecord.IsDBNull(myDataRecord.GetOrdinal("ContactEmail")))
            {
                myEnquiryTable.ContactEmail = myDataRecord.GetString(myDataRecord.GetOrdinal("ContactEmail"));
            }
            if (!myDataRecord.IsDBNull(myDataRecord.GetOrdinal("PreferContactTypeCode")))
            {
                myEnquiryTable.PreferContactTypeCode = myDataRecord.GetInt16(myDataRecord.GetOrdinal("PreferContactTypeCode"));
            }
            if (!myDataRecord.IsDBNull(myDataRecord.GetOrdinal("RelationshipTypeCode")))
            {
                myEnquiryTable.RelationshipTypeCode = myDataRecord.GetInt16(myDataRecord.GetOrdinal("RelationshipTypeCode"));
            }
            if (!myDataRecord.IsDBNull(myDataRecord.GetOrdinal("Message")))
            {
                myEnquiryTable.Message = myDataRecord.GetString(myDataRecord.GetOrdinal("Message"));
            }
            if (!myDataRecord.IsDBNull(myDataRecord.GetOrdinal("Remark")))
            {
                myEnquiryTable.Remark = myDataRecord.GetString(myDataRecord.GetOrdinal("Remark"));
            }
            if (!myDataRecord.IsDBNull(myDataRecord.GetOrdinal("OtherInfo")))
            {
                myEnquiryTable.OtherInfo = myDataRecord.GetString(myDataRecord.GetOrdinal("OtherInfo"));
            }
            if (!myDataRecord.IsDBNull(myDataRecord.GetOrdinal("Status")))
            {
                myEnquiryTable.Status = myDataRecord.GetByte(myDataRecord.GetOrdinal("Status"));
            }
            if (!myDataRecord.IsDBNull(myDataRecord.GetOrdinal("CreatedDateTime")))
            {
                myEnquiryTable.CreatedDateTime = myDataRecord.GetDateTime(myDataRecord.GetOrdinal("CreatedDateTime"));
            }
            if (!myDataRecord.IsDBNull(myDataRecord.GetOrdinal("ModifiedDateTime")))
            {
                myEnquiryTable.ModifiedDateTime = myDataRecord.GetDateTime(myDataRecord.GetOrdinal("ModifiedDateTime"));
            }
            if (!myDataRecord.IsDBNull(myDataRecord.GetOrdinal("Info1")))
            {
                myEnquiryTable.Info1 = myDataRecord.GetString(myDataRecord.GetOrdinal("Info1"));
            }
            if (!myDataRecord.IsDBNull(myDataRecord.GetOrdinal("Info2")))
            {
                myEnquiryTable.Info2 = myDataRecord.GetString(myDataRecord.GetOrdinal("Info2"));
            }
            if (!myDataRecord.IsDBNull(myDataRecord.GetOrdinal("Info3")))
            {
                myEnquiryTable.Info3 = myDataRecord.GetString(myDataRecord.GetOrdinal("Info3"));
            }
            if (!myDataRecord.IsDBNull(myDataRecord.GetOrdinal("Info4")))
            {
                myEnquiryTable.Info4 = myDataRecord.GetString(myDataRecord.GetOrdinal("Info4"));
            }
            if (!myDataRecord.IsDBNull(myDataRecord.GetOrdinal("Info5")))
            {
                myEnquiryTable.Info5 = myDataRecord.GetString(myDataRecord.GetOrdinal("Info5"));
            }
            if (!myDataRecord.IsDBNull(myDataRecord.GetOrdinal("Info6")))
            {
                myEnquiryTable.Info6 = myDataRecord.GetString(myDataRecord.GetOrdinal("Info6"));
            }
            if (!myDataRecord.IsDBNull(myDataRecord.GetOrdinal("Info7")))
            {
                myEnquiryTable.Info7 = myDataRecord.GetString(myDataRecord.GetOrdinal("Info7"));
            }
            if (!myDataRecord.IsDBNull(myDataRecord.GetOrdinal("Info8")))
            {
                myEnquiryTable.Info8 = myDataRecord.GetString(myDataRecord.GetOrdinal("Info8"));
            }
            if (!myDataRecord.IsDBNull(myDataRecord.GetOrdinal("Info9")))
            {
                myEnquiryTable.Info9 = myDataRecord.GetString(myDataRecord.GetOrdinal("Info9"));
            }
            if (!myDataRecord.IsDBNull(myDataRecord.GetOrdinal("Info10")))
            {
                myEnquiryTable.Info10 = myDataRecord.GetString(myDataRecord.GetOrdinal("Info10"));
            }
            if (!myDataRecord.IsDBNull(myDataRecord.GetOrdinal("DInfo1")))
            {
                myEnquiryTable.DInfo1 = myDataRecord.GetDateTime(myDataRecord.GetOrdinal("DInfo1"));
            }
            if (!myDataRecord.IsDBNull(myDataRecord.GetOrdinal("DInfo2")))
            {
                myEnquiryTable.DInfo2 = myDataRecord.GetDateTime(myDataRecord.GetOrdinal("DInfo2"));
            }
            if (!myDataRecord.IsDBNull(myDataRecord.GetOrdinal("DInfo3")))
            {
                myEnquiryTable.DInfo3 = myDataRecord.GetDateTime(myDataRecord.GetOrdinal("DInfo3"));
            }
            if (!myDataRecord.IsDBNull(myDataRecord.GetOrdinal("DInfo4")))
            {
                myEnquiryTable.DInfo4 = myDataRecord.GetDateTime(myDataRecord.GetOrdinal("DInfo4"));
            }
            if (!myDataRecord.IsDBNull(myDataRecord.GetOrdinal("NInfo1")))
            {
                myEnquiryTable.NInfo1 = myDataRecord.GetByte(myDataRecord.GetOrdinal("NInfo1"));
            }
            if (!myDataRecord.IsDBNull(myDataRecord.GetOrdinal("NInfo2")))
            {
                myEnquiryTable.NInfo2 = myDataRecord.GetByte(myDataRecord.GetOrdinal("NInfo2"));
            }
            if (!myDataRecord.IsDBNull(myDataRecord.GetOrdinal("NInfo3")))
            {
                myEnquiryTable.NInfo3 = myDataRecord.GetInt16(myDataRecord.GetOrdinal("NInfo3"));
            }
            if (!myDataRecord.IsDBNull(myDataRecord.GetOrdinal("Ninfo4")))
            {
                myEnquiryTable.Ninfo4 = myDataRecord.GetInt16(myDataRecord.GetOrdinal("Ninfo4"));
            }
            if (!myDataRecord.IsDBNull(myDataRecord.GetOrdinal("NInfo5")))
            {
                myEnquiryTable.NInfo5 = myDataRecord.GetInt32(myDataRecord.GetOrdinal("NInfo5"));
            }
            if (!myDataRecord.IsDBNull(myDataRecord.GetOrdinal("NInfo6")))
            {
                myEnquiryTable.NInfo6 = myDataRecord.GetInt32(myDataRecord.GetOrdinal("NInfo6"));
            }
            if (!myDataRecord.IsDBNull(myDataRecord.GetOrdinal("NInfo7")))
            {
                myEnquiryTable.NInfo7 = myDataRecord.GetInt64(myDataRecord.GetOrdinal("NInfo7"));
            }
            if (!myDataRecord.IsDBNull(myDataRecord.GetOrdinal("NInfo8")))
            {
                myEnquiryTable.NInfo8 = myDataRecord.GetInt16(myDataRecord.GetOrdinal("NInfo8"));
            }
            return myEnquiryTable;
        }
    }

}
